# coding=utf-8

# 导入相应的python包
from pyimagesearch.transform import four_point_transform
import numpy as np
import argparse
import cv2

# 进行参数设置和参数解析
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help = "path to the image file")
ap.add_argument("-c", "--coords", help = "comma seperated list of source points")
args = vars(ap.parse_args())

# 读取图片
image = cv2.imread(args["image"])
# 获取原始的坐标点
pts = np.array(eval(args["coords"]), dtype = "float32")

# 对原始图片进行变换
warped = four_point_transform(image, pts)

# 结果显示
cv2.imshow("Original", image)
cv2.imshow("Warped", warped)
cv2.waitKey(0)
